import torch
import numpy as np
import pandas as pd
#自定义文件导入
from env import Creator, Packer
import sseHp
import torch.nn.functional as F
import math
#全局变量 超参
hp = sseHp.Hyperparameter() #因为是类，所以需要创建实例
creator = Creator() #不用初始化,只调用方法，属于方法工具类，因为是类，所以需要创建实例
_, _, _, car_list_actual = creator.car_list_create()

def get_total_number_and_proportion(averageProportion,upperLimitOfSpace, numberOfCars):
    #averageProportion 需要的平均空间利用率值
    #upperLimitOfSpace 空间利用率上限
    #numberOfCars 车厢数量
    car_volum = car_list_actual[0].length * car_list_actual[0].width * car_list_actual[0].height
    total_volum = numberOfCars * car_volum
    x1, y1, z1 = 6., 7., 8.  #
    x2, y2, z2 = 4., 5., 6.  #
    x3, y3, z3 = 2., 2., 2.  #
    x4, y4, z4 = 3., 4., 5.  #
    v1 = x1 * y1 * z1
    v2 = x2 * y2 * z2
    v3 = x3 * y3 * z3
    v4 = x4 * y4 * z4
    portion = [0,0,0,0]
    #生成每类货箱的数量
    portion[0] = 20
    portion[1] = 20
    portion[2] = 20
    portion[3] = math.ceil((total_volum * averageProportion - portion[2] * v3 - portion[1] * v2 - portion[0] * v1) / v4)

    items_volum = v1 * portion[0] + v2 * portion[1] + v3 * portion[2] + v4 * portion[3]
    su = items_volum / total_volum
    if averageProportion < su:# and su < upperLimitOfSpace:
        return portion, su


    return [0,0,0,0], 0


if __name__ == '__main__':
    #file_name = hp.ITEMS_FILE_RANDOM_PROFIT_ASU_ACTUAL
    #items_data = torch.load(file_name)
    proportion, su = get_total_number_and_proportion(0.7, 0.8, 2)
    print(proportion, su)





